package com.sskj.one.mine;


import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;
import com.sskj.one.bean.AssetListBean;
import com.sskj.one.bean.PageBean;
import com.sskj.one.presenter.BasePresenter;

import java.util.List;

import io.reactivex.Flowable;

/**
 * @author Hey
 * Create at  2019/05/22
 */
class AssetDetailPresenter extends BasePresenter<AssetDetailActivity> {

//    public Flowable<List<AssetListBean>> getAssetRecord(int page, int size) {
//        return httpService.getAsssetRecord(page, size)
//                .tag(this)
//                .converter(new JsonConverter<HttpData<PageBean<AssetListBean>>>() {
//                })
//                .adapt(new FlowableBody<>())
//                .map(HttpData -> HttpData.getData().getLists());
//    }

    public void getAssetRecord(int page, int size) {
        httpService.getAsssetRecord(page, size)
                .tag(this)
                .execute(new JsonCallBack<HttpData<PageBean<AssetListBean>>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<PageBean<AssetListBean>> data) {
                        mView.getAssetRecordOK(data.getData().getLists());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });

    }

}
